Book Contents

Left Shift operator ( << )

Shifts the bits within the left operand by the amount specified in the right operand. The bit on the left disappears and a 0 is shifted in on the right.

If the left bit is a 1 an overflow will occur, and an error message is displayed. To prevent this, use the bitwise AND (&) operator in an expression. For example:

(dev << 1) & 65535 where 65535 is 1111 1111 1111 1111 in binary form.

where dev is a tag name, whose value is being shifted left.

See also

Quick reference to operators